/*
 * logger.js
 */
if (typeof Logger == "undefined") {

	function Logger(prefix) {
		this._prefix = prefix ? prefix : "";
		this._enabled = false;
		this._level = 3;
	}

	Logger.prototype = {

		trace : function() {
			if (this._level >= 3) {
				this._dumpMsg("DEBUG", "------Just Tracing------");
			}
		},

		debug : function(msg) {
			if (this._level >= 3) {
				this._dumpMsg("DEBUG", msg);
			}
		},

		info : function(msg) {
			if (this._level >= 2) {
				this._dumpMsg("INFO", msg);
			}
		},

		error : function(msg) {
			if (this._level >= 1) {
				this._dumpMsg("ERROR", msg);
			}
		},

		setLevel : function(level) {
			this._level = level;
		},

		_dumpMsg : function(strLevel, msg) {
			var date = new Date();
			var time = date.getFullYear() + "-" + date.getMonth() + "-"
					+ date.getDate() + " " + date.getHours() + ":"
					+ date.getMinutes() + ":" + date.getSeconds();
			var _msg = time + " [" + this._prefix + "]-[" + strLevel + "]: "
					+ msg;
			Components.classes["@mozilla.org/consoleservice;1"]
					.getService(Components.interfaces.nsIConsoleService)
					.logStringMessage(_msg);
		}
	};
} else {
	dump("WARM: exist two Logger definitions !");
}